"use strict";
{
    //声明函数                     3            'love'
    function createArray(count, value) {
        //声明一个数组
        let arr = [];
        //创建
        for (let i = 0; i < count; i++) {
            arr.push(value);
        }
        //返回数组
        return arr;
    }
    //调用函数
    let arr = createArray(3, "iloveyou");
    // console.log(arr[0].slice(1, 5))
    // console.log(arr[0].toFixed(2));
}
{
    //声明函数         泛型变量, 保存类型, 泛型变量的名字没有特殊限制, 常用的名字有 T P V A B C c
    function createArray(count, value) {
        //声明一个数组
        let arr = [];
        //创建
        for (let i = 0; i < count; i++) {
            arr.push(value);
        }
        //返回数组
        return arr;
    }
    //调用函数
    let arr = createArray(3, "iloveyou");
    console.log(arr[0].slice(1, 5));
    // console.log(arr[0].toFixed(2));
}
{
    //声明函数, 创建数组
    function createArray(v1, v2) {
        return [v1, v2];
    }
    let res = createArray("白色", 18);
    // res[0].toFixed();
    // res[1].toFixed();
}
{
    let res = {
        status: 200,
        statusText: "OK",
        headers: {
            contentType: "xxx",
        },
        data: {
            id: 1,
            title: "西游记",
            price: 19.0,
        },
    };
    let res2 = {
        status: 200,
        statusText: "OK",
        headers: {
            contentType: "xxx",
        },
        data: {
            id: 2,
            name: "zhangsan",
            age: 18,
        },
    };
}
{
    let res = {
        status: 200,
        statusText: "OK",
        headers: {
            contentType: "xxx",
        },
        data: {
            code: "0000",
            msg: "获取成功",
            data: {
                id: 1,
                title: "西游记",
                price: 19.0,
            },
        },
    };
    let res2 = {
        status: 200,
        statusText: "OK",
        headers: {
            contentType: "xxx",
        },
        data: {
            code: '0000',
            msg: '获取成功',
            data: {
                id: 2,
                name: "zhangsan",
                age: 18,
            }
        },
    };
    // res.data.data.abc
}
{
    //泛型类   字符串的数组
    class Container {
        constructor(arg) {
            this.store = arg;
        }
        add(str) {
            this.store.push(str);
        }
        del() {
            this.store.pop();
        }
    }
    //实例化
    let c = new Container([1, 2, 3]);
    let c2 = new Container([]);
    c2.add({ id: 2, title: '三国演义', price: 9.9 });
}
{
    //通过 ctrl + 点击的方式可以查看内部的声明
    let arr = ['1', '2', '3'];
    let p = new Promise((resolve, reject) => {
        resolve(20);
    });
}
{
    function main(arg) {
        console.log(arg.length);
    }
    // main(123);
    // main('123');
    main([1, 2, 3]);
}
